home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-03
/
apb17.zip
/
MOUSE.BAS
< prev
next >
Wrap
BASIC Source File
|
1990-12-20
|
4KB
|
151 lines
' Include file of Subprograms and Functions for using a
' Microsoft compatible mouse (Tested with Logitech)
' This include file uses 2 assembler files: Int.com and MouseI.com
' Subprogram to do software interrupts
Sub DoInt IntNo%,Reg%(1) External "Int.Com"
' Assign a trap # to a mouse event
Sub SetMouseTrap CondMask%,TrapNo% External "MouseI.Com"
' Reset the mouse trap
Sub ResetMouseTrap External "" 3
' Return information after a mouse interrupt
Sub GetMouseInfo CondMask%,Hpos%,Vpos%,Buttons% External "" 6
' Constants for Condition mask. OR these together to trap
' multiple mouse events
Const Ms.Pos%=1 ' Mouse position changed
Const Ms.LeftDn%=2 ' Left button pressed
Const Ms.LeftUp%=4 ' Left button released
Const Ms.RightDn%=8 ' Right button pressed
Const Ms.RightUp%=16 ' Right button released
Const Ms.MiddleUp%=32 ' Middle button pressed
Const Ms.MiddleDn%=64 ' Middle button released
' Function to peek an integer
Def PeekWord%(Offset%)
PeekWord%=Peek(Offset%)+(Peek(Offset%+1) Shl 8)
End Def
' ----------- Start of Mouse functions ----------------------
' Array used when for holding machine registers
' when doing interrupts to the mouse software
Dim MouseRegs%(0 to 9)
' Constants for accessing the above array
Const Flags=0
Const Ax=1
Const Bx=2
Const Cx=3
Const Dx=4
Const Si=5
Const Di=6
Const Bp=7
Const Ds=8
Const Es=9
' Check if the Mouse is available and
' initialize.
' Returns:
' 0 = Not available. Don't do any mouse functions if
' if this Def returns zero.
' 1 = Mouse available.
Def MouseInit%()
Local MouseSeg%,MouseOff%
Def Seg=0
MouseOff%=PeekWord%(&h33*4+2)
MouseSeg%=PeekWord%(&h33*4)
MouseInit%=1 ' Assume it's there
If MouseSeg%=0 And MouseOff%=0 then
MouseInit%=0 ' INT vector is zero
Else
Def Seg=MouseSeg%
If Peek(MouseOff%)=&hcf Then
MouseInit%=0 ' INT vector points to IRET
Else
MouseRegs%(Ax)=0
DoInt &h33,MouseRegs%()
If MouseRegs%(Ax)=0 Then
MouseInit%=0
End If
End If
End If
End Def
' Show the mouse cursor
Sub MouseShow
MouseRegs%(Ax)=1
DoInt &h33,MouseRegs%()
End Sub
' Hide the mouse cursor
Sub MouseHide
MouseRegs%(Ax)=2
DoInt &h33,MouseRegs%()
End Sub
' Set mouse cursor to a position on the screen
Sub MouseSet HPos%, VPos%
MouseRegs%(Cx)=HPos%
MouseRegs%(Dx)=VPos%
MouseRegs%(Ax)=4
DoInt &h33,MouseRegs%()
End Sub
' Return mouse status
' Be sure to pass actual variables to this subprogram, not expressions
Sub MouseStatus Hpos%, Vpos%, Buttons%
MouseRegs%(Ax)=3
DoInt &h33,MouseRegs%()
Hpos%=MouseRegs%(Cx)
Vpos%=MouseRegs%(Dx)
Buttons%=MouseRegs%(Bx)
End Sub
' Return the distance mouse moved since last call
Sub MouseMotion Hpos%, Vpos%
MouseRegs%(Ax)=11
DoInt &h33,MouseRegs%()
Hpos%=MouseRegs%(Cx)
Vpos%=MouseRegs%(Dx)
End Sub
' Define the region to restrict the mouse
' UpH%=Upper left horizontal pos of region
' UpV%=Upper left vertical " " "
' LowerH%=Lower right horizontal pos of region
' LowerV%=Lower right vertical " " "
' NOTE: The coordinates of the region is in pixels, NOT character
' coordinates. ROW=MousePosV/8+1, COL=MousePosH/8+1
' MousePosV=(ROW-1)*8, MousePosH=(COL-1)*8
Sub MouseBounds UpV%,UpH%,LowerV%,LowerH%
MouseRegs%(Cx)=UpH%
MouseRegs%(Dx)=LowerH%
MouseRegs%(Ax)=7
DoInt &h33,MouseRegs%() ' Set horizontal limits
MouseRegs%(Cx)=UpV%
MouseRegs%(Dx)=LowerV%
MouseRegs%(Ax)=8
DoInt &h33,MouseRegs%() ' Set vertical limits
End Sub
' Define the region to not display the mouse
' UpH%=Upper left horizontal pos of region
' UpV%=Upper left vertical " " "
' LowerH%=Lower right horizontal pos of region
' LowerV%=Lower right vertical " " "
' NOTE: The coordinates of the region is in pixels, NOT character
' coordinates. ROW=MousePosV/8+1, COL=MousePosH/8+1
' MousePosV=(ROW-1)*8, MousePosH=(COL-1)*8
Sub MouseRegion UpV%,UpH%,LowerV%,LowerH%
MouseRegs%(Cx)=UpH%
MouseRegs%(Dx)=UpV%
MouseRegs%(Si)=LowerH%
MouseRegs%(Di)=LowerH%
MouseRegs%(Ax)=16
DoInt &h33,MouseRegs%()
End Sub
' ------------- End Of Mouse Functions -------------------